//
//  UtilsMacros.swift
//  UniversalProject-Swift
//
//  Created by apple on 2019/7/11.
//  Copyright © 2019 apple. All rights reserved.
//

// 全局工具类宏定义

import Foundation

////获取系统对象
//#define kApplication        [UIApplication sharedApplication]
//#define kAppWindow          [UIApplication sharedApplication].delegate.window
//#define kAppDelegate        [AppDelegate shareAppDelegate]
//#define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController
//#define kUserDefaults       [NSUserDefaults standardUserDefaults]
//#define kNotificationCenter [NSNotificationCenter defaultCenter]
//#define kMainTabBarVC (MainTabBarViewController *)kAppDelegate.tabBarController
//
////不包括状态栏的导航高度
//#define kUnStatusNavH 44
//#define kStatusBarHeight (kISIPHONEX ? 44 : 20)
//#define kNavBarHeight (kStatusBarHeight + kUnStatusNavH)
//#define kTabBarHeight (kISIPHONEX ? 83 : 49)
//#define kTopHeight (kStatusBarHeight + kNavBarHeight)
//#define kTabImageMargin (kISIPHONEX ? 40 : 10)
//
////获取屏幕宽高
//#define KScreenWidth ([[UIScreen mainScreen] bounds].size.width)
//#define KScreenHeight ([[UIScreen mainScreen] bounds].size.height)
//#define kScreen_Bounds [UIScreen mainScreen].bounds
//
//#define Iphone6ScaleWidth KScreenWidth/375.0
//#define Iphone6ScaleHeight KScreenHeight/667.0
////根据ip6的屏幕来拉伸
//#define kRealValue(with) ((with)*(KScreenWidth/375.0f))
//
////强弱引用
//#define kWeakSelf(weakSelf) __weak __typeof(self) weakSelf = self;
//#define kStrongSelf(type) __strong typeof(type) type = weak##type;
//
////View 圆角和加边框
//#define ViewBorderRadius(View, Radius, Width, Color)\
//\
//[View.layer setCornerRadius:(Radius)];\
//[View.layer setMasksToBounds:YES];\
//[View.layer setBorderWidth:(Width)];\
//[View.layer setBorderColor:[Color CGColor]]
//
//// View 圆角
//#define ViewRadius(View, Radius)\
//\
//[View.layer setCornerRadius:(Radius)];\
//[View.layer setMasksToBounds:YES]
//
////property 属性快速声明 别用宏定义了，使用代码块+快捷键实现吧
//
//// 当前系统版本
//#define CurrentSystemVersion [[UIDevice currentDevice].systemVersion doubleValue]
////App版本
//#define kAPP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
////当前语言
//#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
////判断是否是iphoneX XS
//#define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size)) : NO)
//// 判断iPHoneXR
//#define IS_IPHONE_XR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
//// 判断iPhoneXs_Max
//#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
//// X、XR、XS、XS_MAX系列
//#define kISIPHONEX ((IS_IPHONE_X == YES || IS_IPHONE_XR == YES || IS_IPHONE_Xs_Max == YES) ? YES : NO)
//
////-------------------打印日志-------------------------
///**
// *  工程全局环境控制
// *
// *  0:开发环境  1:发布环境
// */
//#if (ENV_CONFIG_TYPE == 0)
//#define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d] \n" fmt), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
//#define DeBugLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
//#define NSLog(...) NSLog(__VA_ARGS__);
//#define MyNSLog(FORMAT, ...) fprintf(stderr,"[%s]:[line %d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//#endif
//
//#if (ENV_CONFIG_TYPE == 1)
//#define DLog(...)
//#define DeBugLog(...)
//#define NSLog(...)
//#define MyNSLog(FORMAT, ...) nil
//#endif
//
////拼接字符串
//#define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]
////过滤字符串
//#define KNBLimitString(string, index) (!isNullStr(string) && string.length > index) ? [string substringWithRange:NSMakeRange(0, index)] : string;
//
////颜色
//#define KClearColor [UIColor clearColor]
//#define KWhiteColor [UIColor whiteColor]
//#define KBlackColor [UIColor blackColor]
//#define KGrayColor [UIColor grayColor]
//#define KGray2Color [UIColor lightGrayColor]
//#define KBlueColor [UIColor blueColor]
//#define KRedColor [UIColor redColor]
//#define kRandomColor    KRGBColor(arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0)        //随机色生成
//#define kRGBA(r, g, b, a) [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:a]
//#define kRGB(r, g, b) [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:1.0]
//
////字体
//#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
//#define SYSTEMFONT(FONTSIZE)    [UIFont systemFontOfSize:FONTSIZE]
//#define FONT(NAME, FONTSIZE)    [UIFont fontWithName:(NAME) size:(FONTSIZE)]
//
////数据验证
//#define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
//#define SafeStr(f) (StrValid(f) ? f:@"")
//#define HasString(str,key) ([str rangeOfString:key].location!=NSNotFound)
//
//#define ValidStr(f) StrValid(f)
//#define ValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]])
//#define ValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)
//#define ValidNum(f) (f!=nil && [f isKindOfClass:[NSNumber class]])
//#define ValidClass(f,cls) (f!=nil && [f isKindOfClass:[cls class]])
//#define ValidData(f) (f!=nil && [f isKindOfClass:[NSData class]])
//
////获取一段时间间隔
//#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
//#define kEndTime  NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)
////打印当前方法名
//#define ITTDPRINTMETHODNAME() ITTDPRINT(@"%s", __PRETTY_FUNCTION__)
//
//
////发送通知
//#define KPostNotification(name,obj) [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj];
//
////单例化一个类
//#define SINGLETON_FOR_HEADER(className) \
//\
//+ (className *)shared##className;
//
//#define SINGLETON_FOR_CLASS(className) \
//\
//+ (className *)shared##className { \
//    static className *shared##className = nil; \
//    static dispatch_once_t onceToken; \
//    dispatch_once(&onceToken, ^{ \
//    shared##className = [[self alloc] init]; \
//    }); \
//    return shared##className; \
//}
//
//#define SINGLETON_FOR_DEFAULT(className) \
//\
//+ (className *)shareInstance { \
//    static className *shared##className = nil; \
//    static dispatch_once_t onceToken; \
//    dispatch_once(&onceToken, ^{ \
//    shared##className = [[self alloc] init]; \
//    }); \
//    return shared##className; \
//}
